package com.lhj.demo.simple.controller;

import com.lhj.demo.simple.annotation.Log;
import com.lhj.demo.simple.domain.dto.QueryDTO;
import com.lhj.demo.simple.service.AnnotationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hj.luo
 * @Date 2023-07-19 10:01
 * @descripition
 * @version: 1.0
 */
@RestController
@RequestMapping("/annotation")
public class AnnotationController {
    @Autowired
    AnnotationService annotationService;

    @Log(module = "TEST", operatorType = "USER")
    @GetMapping("/test")
    public Integer test(@RequestParam("type") String type, QueryDTO queryDTO) {
        Integer row = null;
        switch (type) {
            case "error":
                throw new Error("error");
                // break;
            case "exception":
                throw new RuntimeException("exception");
                // break;
            default:
                row = annotationService.run(queryDTO);
                break;
        }

        return row;
    }
}
